﻿@model IEnumerable<vnMcdonald.Models.Cart>

@{
    ViewBag.Title = "Cart";
}
    <div class="cart">
        <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
            <h3 id="myModalLabel">Bữa ăn của bạn</h3>
        </div>
        <div class="modal-body">
            <table class="table table-striped">
                <thead>
                <tr>
                    <th style="width: 40%">
                        @Html.DisplayNameFor(model => model.Name)
                    </th>
                    <th style="width: 15%">
                        @Html.DisplayNameFor(model => model.Image)
                    </th>
                    <th style="width: 15%">
                        @Html.DisplayNameFor(model => model.Quantity)
                    </th>
                    <th style="width: 15%">
                        @Html.DisplayNameFor(model => model.Price)
                    </th>
                    <th style="width: 15%">Hành động</th>
                </tr>
                </thead>
                <tbody>
                @if(Model != null && Model.Count() > 0){
                foreach (var item in Model) {
                    <tr>
        
                        <td>
                            @Html.DisplayFor(modelItem => item.Name)
                        </td>
                        <td class="image text-center">
                            <img src="@item.Image" alt="@item.Name" />
                        </td>
                        <td class="text-center">
                            @Html.TextBoxFor(modelItem => item.Quantity, new { @class = "input-quantity-2", name="Quantity", id ="input-quantity-"+@item.RecordId})
                        </td>
                        <td class="text-center">
                            @Html.DisplayFor(modelItem => item.Price) VNĐ
                        </td>
                        <td class="text-center">
                            @Html.ActionLink(" ", "SaveCart", "Cart", new { ProductId = item.ProductId }, new { @class = "save-icon", onclick = "return saveCart(this)" }) 
                            @Html.ActionLink(" ", "DeleteCart", "Cart", new { ProductId = item.ProductId }, new { @class = "delete-icon", onclick = "return deleteCart(this)"})                            
                        </td>
                    </tr>
                }
                    <tr>
                        <td colspan="5" class="price">
                            Tổng tiền: <span>@string.Format("{0:0,0}", ViewBag.TotalCart) VNĐ</span>
                        </td>
                    </tr>
                }else{
                    <tr>
                        <td colspan="5" class="empty-cart">
                            Chưa có món ăn trong bữa ăn của bạn
                        </td>
                    </tr>
                }
                </tbody>
            </table>
        </div>
        <div class="modal-footer">
            @if(Model != null && Model.Count() > 0){
                @Ajax.ActionLink("Hủy bữa ăn", "ClearCart", "Cart", null, new AjaxOptions{
                    HttpMethod = "Post",
                    OnSuccess = "clearCartSuccess"
                }, new { @class="btn btn-warning pull-left"})
                <a class="btn btn-info pull-right" href="#modal-payment" role="button" data-toggle="modal" data-backdrop="false" onclick="showPayment()">Thanh toán</a>
            }
            <a class="btn pull-left" href="#product" onclick="return hideCart()">Tiếp tục đặt món</a>
        </div>
    </div>
    <script type="text/javascript">
        $('.input-quantity-2').ChangeQuantity();
    </script>
